<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ include file="header.jsp" %>
    <h1>个人中心</h1>

    <div style="display: flex; margin-top: 30px;">
        <div style="width: 200px; background: white; padding: 20px; margin-right: 20px; border-radius: 5px; box-shadow: 0 2px 5px rgba(0,0,0,0.1);">
            <div style="text-align: center; margin-bottom: 20px;">
                <div style="width: 100px; height: 100px; background-color: #3498db; border-radius: 50%; margin: 0 auto 10px; display: flex; align-items: center; justify-content: center; color: white; font-size: 40px;">
                    ${sessionScope.user.username.charAt(0)}
                </div>
                <h3>${sessionScope.user.username}</h3>
            </div>
            <ul style="list-style: none;">
                <li style="margin-bottom: 10px;"><a href="${pageContext.request.contextPath}/user-center.jsp" style="text-decoration: none; color: #2c3e50;">我的资料</a></li>
                <li style="margin-bottom: 10px;"><a href="${pageContext.request.contextPath}/blog/my" style="text-decoration: none; color: #2c3e50;">我的博客</a></li>
                <li><a href="${pageContext.request.contextPath}/user/logout" style="text-decoration: none; color: #2c3e50;">退出登录</a></li>
            </ul>
        </div>

        <div style="flex: 1; background: white; padding: 20px; border-radius: 5px; box-shadow: 0 2px 5px rgba(0,0,0,0.1);">
            <h2>我的资料</h2>
            <form action="${pageContext.request.contextPath}/user/update" method="post" style="margin-top: 20px;">
                <div style="margin-bottom: 15px;">
                    <label>用户名:</label>
                    <p style="padding: 8px; background-color: #f9f9f9; border-radius: 4px;">${sessionScope.user.username}</p>
                </div>
                <div style="margin-bottom: 15px;">
                    <label for="email">邮箱:</label>
                    <input type="email" id="email" name="email" value="${sessionScope.user.email}" style="width: 100%; padding: 8px; margin-top: 5px;">
                </div>
                <div style="margin-bottom: 15px;">
                    <label for="password">新密码 (留空则不修改):</label>
                    <input type="password" id="password" name="password" style="width: 100%; padding: 8px; margin-top: 5px;">
                </div>
                <button type="submit" class="btn">保存更改</button>
                <c:if test="${not empty success}">
                    <p class="success" style="margin-top: 10px;">${success}</p>
                </c:if>
                <c:if test="${not empty error}">
                    <p class="error" style="margin-top: 10px;">${error}</p>
                </c:if>
            </form>
        </div>
    </div>
<%@ include file="footer.jsp" %>